<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/react.development.js"></script>
    <script src="js/react-dom.development.js"></script>
    <script src="js/babel.min.js"></script>
</head>
<body>
    <div id="root"></div>
    <script type="text/babel">
        class HelloTom extends React.Component{

            fnHello(){
                alert("Hello,Tom");
            }
            render(){
                return(
                    <input type="button" value="打招呼" onClick={this.fnHello}/>
                );
            }
        }

        class HelloName extends React.Component{
            fnHello(){
                alert("Hello,"+this.props.name);
            }
            render(){
                return(
                    <input type="button" value="打招呼" onClick={this.fnHello.bind(this)}/>
                );
            }
        }
        ReactDOM.render(
            // <HelloTom />,
            <HelloName name = "Bob" />,
            document.getElementById("root")
        );
    </script>
</body>
</html>